package com.woniuxy.rabbitmq83.simple;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * description: Productor <br>
 * date: 2022/1/12 3:48 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */

/**
 * 消息生产者
 */
@Component
public class Productor {
    @Resource
    //注入的是 RabbitTemplate
    private AmqpTemplate amqpTemplate;

    //发送消息
    public void send(String message) {
        System.out.println("begin send");
        //参数1：消息队列的名字
        //参数2：消息内容 object
        for (int i = 0; i < 10; i++) {
            amqpTemplate.convertAndSend("simple", message);
        }
    }
}
